package com.lxb.myforum.controller.admin.sysmgt

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpSession

import com.lxb.myforum.base.BaseController
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping

import com.lxb.myforum.service.ArticleService
import com.lxb.myforum.service.CommentService
import com.lxb.myforum.service.UserService

/**
 *
 * @author lxb
 */
@Controller("sysMgtCtrl")
@RequestMapping(value = ["/admin/sysmgt"])
class SysMgtController @Autowired constructor(
        private val userService: UserService,
        private val articleService: ArticleService,
        private val commentService: CommentService
) : BaseController() {

    @GetMapping(value = ["", "/", "/index"])
    fun index(session: HttpSession, request: HttpServletRequest): String {
        val count = userService.count()
        request.setAttribute("userCount", count)
        request.setAttribute("articleCount", articleService.count())
        request.setAttribute("commentCount", commentService.count())

        return "/admin/sysmgt/index"
    }
}
